<?php $user = App\Models\User::find($token['user_id']);?>
<nav class="navbar-default navbar-static-side" role="navigation">
  <div class="sidebar-collapse">
    <ul id="side-menu" class="nav metismenu">
      <li class="nav-header">
        <div class="dropdown profile-element">
          <span>
            <img alt="image" class="img-circle" src="{{get_photo(session('token')['user_id'])}}" width="50" />
          </span>
          <a href="javascript:;" data-toggle="dropdown" class="dropdown-toggle">
            <span class="clear">
              <span class="block m-t-xs">
                <strong class="font-bold">{{session('token')['realname']}}</strong>
              </span>
              <span class="text-muted text-xs block">
                欢迎您 <b class="caret"></b>
              </span>
            </span>
          </a>
          <ul class="dropdown-menu animated fadeInRight m-t-xs">
            <li><a href="profile.html"><i class="fa fa-user"></i> 个人资料</a></li>
            <li><a href="contacts.html"><i class="fa fa-key"></i> 修改密码</a></li>
            <li class="divider"></li>
            <li><a href="{{url('admin/account/logout')}}" onclick="return confirm('您确定要退出吗？');"><i class="fa fa-sign-out"></i> 退出</a></li>
          </ul>
        </div>
        <div class="logo-element"><i class="fa fa-bars"></i></div>
      </li>
      <li rel="welcome">
        <a href="{{url('admin')}}"> <i class="fa fa-flag"></i>
          <span class="nav-label">欢迎您</span>
        </a>
      </li>
      @if($user->can('news'))
      <?php
      $j = 1;
      $newsclass = new \App\Models\Newsclass;
      $rows = $newsclass->getTree();
      foreach ($rows as $row):
        if ($row->depth < $j):
          $n = $j - $row->depth;
          for ($m = 0; $m < $n; $m++):
            echo '</ul></li>';
          endfor;
        endif;
        if ($row->child > 0):
      ?>
        <li rel="news-{{$row->id}}">
          <a href="{{url('admin/newsinfo/list/'.$row->id)}}">
            <i class="fa fa-th-list"></i>
            <span class="nav-label">{{$row->name}}</span>
            <span class="fa arrow"></span>
          </a>
          <ul class="nav nav-second-level">
      <?php else: ?>
        <li rel="news-{{$row->id}}">
          <a href="{{url('admin/newsinfo/list/'.$row->id)}}">{{$row->name}}</a>
        </li>
      <?php
        endif;
        if ($row->depth > $j):
          $j++;
        elseif ($row->depth < $j):
          $j--;
        endif;
      endforeach;
      for ($m = 1; $m < $j; $m++):
        echo '</ul></li>';
      endfor;
      ?>
      @if($token['isHidden'])
      <li rel="news">
        <a href="javascript:;">
          <i class="fa fa-sitemap"></i>
          <span class="nav-label">资讯管理</span>
          <span class="fa arrow"></span>
        </a>
        <ul class="nav nav-second-level">
          <li rel="1">
            <a href="{{url('admin/newsclass')}}">栏目结构</a>
          </li>
          <li rel="2">
            <a href="{{url('admin/newsinfo')}}">信息管理</a>
          </li>
          <li rel="3">
            <a href="{{url('admin/newspopedom')}}">权限分配</a>
          </li>
          <li rel="4">
            <a href="{{url('admin/newsclass/tree-list')}}">栏目树结构</a>
          </li>
        </ul>
      </li>
      @endif
      @endif
      <li rel="advanced">
        <a href="javascript:;">
          <i class="fa fa-diamond"></i>
          <span class="nav-label">高级管理</span>
          <span class="fa arrow"></span>
        </a>
        <ul class="nav nav-second-level collapse">
          @if($user->can('link'))
          <li>
            <a href="javascript:;">链接管理 <span class="fa arrow"></span></a>
            <ul class="nav nav-third-level">
              <li rel="link">
                <a href="{{url('admin/link')}}">友情链接</a>
              </li>
              <li rel="linktag">
                <a href="{{url('admin/link/tag-list')}}">链接标签</a>
              </li>
            </ul>
          </li>
          @endif
          @if($user->can('pageadver'))
          <li rel="pageadver">
            <a href="{{url('admin/pageadver')}}">页面图片管理</a>
          </li>
          @endif
          @if($user->can('exam'))
          <li rel="examtopic">
            <a href="{{url('admin/exam/topic')}}">维护练习题</a>
          </li>
          @endif
          @if($user->can('team'))
          <li rel="team">
            <a href="{{url('admin/team/designer-list')}}">设计团队</a>
          </li>
          @endif
          <li rel="userfiles">
            <a href="{{url('admin/userfiles')}}">私人文件柜</a>
          </li>
        </ul>
      </li>
      @if($user->can('siteconfig'))
      <li rel="siteconfig">
        <a href="javascript:;">
          <i class="fa fa-cog"></i>
          <span class="nav-label">站点配置</span>
          <span class="fa arrow"></span>
        </a>
        <ul class="nav nav-second-level">
          <li rel="1">
            <a href="{{url('admin/siteconfig/meta')}}">Meta 设置</a>
          </li>
          <li rel="2">
            <a href="{{url('admin/siteconfig/logo')}}">Logo 图片</a>
          </li>
        </ul>
      </li>
      @endif
      @if($user->can('system'))
      <li rel="entrust">
        <a href="javascript:;">
          <i class="fa fa-cogs"></i>
          <span class="nav-label">系统管理</span>
          <span class="fa arrow"></span>
        </a>
        <ul class="nav nav-second-level">
          <li rel="1">
            <a href="{{url('admin/role')}}">角色管理</a>
          </li>
          <li rel="2">
            <a href="{{url('admin/user')}}">用户管理</a>
          </li>
          <li rel="3">
            <a href="{{url('admin/permission')}}">权限管理</a>
          </li>
        </ul>
      </li>
      @endif
      <li rel="profile">
        <a href="javascript:;">
          <i class="fa fa-user"></i>
          <span class="nav-label">个人管理</span>
          <span class="fa arrow"></span>
        </a>
        <ul class="nav nav-second-level">
          <li rel="1">
            <a href="{{url('admin/profile')}}">基本资料</a>
          </li>
          <li rel="2">
            <a href="{{url('admin/profile/changepwd')}}">修改密码</a>
          </li>
        </ul>
      </li>
    </ul>
  </div>
</nav>